﻿using System;

namespace RestAPI
{
    #region 接口枚举

    /// <summary>
    /// 服务器响应类型
    /// </summary>
    public enum WebRequestError
    {
        成功_200 = 200,                     //服务器接受请求
        参数错误_400 = 400,                 //参数不满足格式要求，或者参数值为空
        验签失败_401 = 401,                 //稍后再试，或者联系运营提供商
        企业不存在或状态异常_403 = 403,     //联系运营提供商
        远程服务器未找到_404 = 404,
        服务暂停_503 = 503,                 //稍后再试，或者联系运营提供商
        类型错误 = -1,
    }

    /// <summary>
    /// 语音接口类型
    /// </summary>
    public enum WebCallType
    {
        /// <summary>
        /// 普通外呼
        /// </summary>
        webcall,
        /// <summary>
        /// 可信语音外呼
        /// </summary>
        webcalltone,
        /// <summary>
        /// 可信文本外呼
        /// </summary>
        webcalltext,
        /// <summary>
        /// 语音验证码
        /// </summary>
        webcallverificationcode,
        /// <summary>
        /// 普通外呼IVR
        /// </summary>
        webcallivr,
        /// <summary>
        /// 坐席组外呼
        /// </summary>
        webcallgroup,
        /// <summary>
        /// 坐席组外呼-可信语音
        /// </summary>
        webcallgrouptone,
        /// <summary>
        /// 营销外呼
        /// </summary>
        webcallwithcollectinfo,
    }

    /// <summary>
    /// 视频接口类型
    /// </summary>
    public enum WebVideoCallType
    {
        /// <summary>
        /// 视频外呼
        /// </summary>
        webvideocall,
        /// <summary>
        /// 视频会议
        /// </summary>
        confcall,
        /// <summary>
        /// 视频会议控制-增加参与方
        /// </summary>
        confctrladd,
        /// <summary>
        /// 视频会议控制-减少参与方（非大画面方）
        /// </summary>
        confctrldel,
        /// <summary>
        /// 视频会议控制-结束会议
        /// </summary>
        confctrlhalt,
        /// <summary>
        /// 视频会议控制-设置大画面
        /// </summary>
        confctrlview,
        /// <summary>
        /// 查询会议状态
        /// </summary>
        getconfinfo,
        /// <summary>
        /// 查询会议成员状态
        /// </summary>
        getconfmemberinfo,
        /// <summary>
        /// 视频会议广播消息
        /// </summary>
        confmsg,
        /// <summary>
        /// 视频会议控制-设置画面布局#
        /// </summary>
        confscreen,
        /// <summary>
        /// 视频会议控制-控制静音哑音
        /// </summary>
        confsilence,
    }

    /// <summary>
    /// 管理接口
    /// </summary>
    public enum ManagerMentType
    {
        /// <summary>
        /// 根据Mac地址查询登录账户
        /// </summary>
        getaccountfrommac,
        /// <summary>
        /// 查询坐席在线状态
        /// </summary>
        getagentstatus,
        /// <summary>
        /// 查询坐席组信息
        /// </summary>
        getgroup,
        /// <summary>
        /// 查询坐席组坐席状态信息
        /// </summary>
        getgroupmember,
        /// <summary>
        /// 查询企业网关可用线路数
        /// </summary>
        getgwstatus,
        /// <summary>
        /// 语音转文本TTS接口
        /// </summary>
        tts,
        /// <summary>
        /// 查询企业密码
        /// </summary>
        querycompanyinfo,
        /// <summary>
        /// 设置坐席忙闲状态
        /// </summary>
        setphonestatus,
        /// <summary>
        /// SSO登录接口
        /// </summary>
        sso,
        /// <summary>
        /// 修改SIP账户密码
        /// </summary>
        changepwd,
        /// <summary>
        /// 创建SIP设备及账户
        /// </summary>
        createdevice,
        /// <summary>
        /// 查询会议成员状态
        /// </summary>
        getconfmemberinfo,
        /// <summary>
        /// 获取企业下视频列表 - 2018/07/03
        /// </summary>
        zwangetvideopath,
    }

    #endregion    

    public class RestAPIModelBase
    {
        #region 字段

        private string companyid;
        private string callflowid;
        private string calling;
        private string callback;
        private string called;
        private string callmode;
        private string playtime;
        private string toneid;
        private string voice_text;
        private string ivrid;
        private string groupid;
        private string collectinfocallback;
        private string input;
        private string content;
        private string confid;
        private string pageno;
        private string pagesize;
        private string mac;
        private string number;
        private string password;
        private string account;
        private string oldpassword;
        private string devicevendorid;
        private string devicetype;
        private string deviceid;
        private string status;
        private string screenmode;
        private string picnum;
        private string title;
        private string rtmppush;
        private string loginname;
        private string filename;
        private string operation;
        #endregion


        #region 属性

        /// <summary>
        /// 企业编号，保存在系统的唯一编号
        /// </summary>
        public string Companyid
        {
            get { return companyid; }
            protected set
            {
                string name = "Companyid";
                int maxLength = 18;
                if (value.Length > maxLength)
                {
                    throw new Exception(name + " Length too long: cur length[" + value.Length + "]" + " max[" + maxLength + "]");
                };
                companyid = value;
            }
        }
        /// <summary>
        /// 呼叫流水号，在同一企业必须保证不重复。建议在流水号中包含时间戳
        /// </summary>
        public string CallFlowid { get { return callflowid; } protected set { callflowid = value; } }
        /// <summary>
        /// 先呼号码，系统先呼叫calling号码，
        /// </summary>
        public string Calling { get { return calling; } protected set { calling = value; } }
        /// <summary>
        /// 呼叫结果回调地址，呼叫完毕后，系统向该地址发送POST请求（见外呼结果通知）
        /// </summary>
        public string Callback { get { return callback; } protected set { callback = value; } }
        /// <summary>
        /// 后呼号码，呼通calling之后再呼叫called，并把二者联系起来。
        /// </summary>
        public string Called { get { return called; } protected set { called = value; } }
        /// <summary>
        /// 呼叫模式0_不需要录音1_需要录音
        /// </summary>
        public string Callmode { get { return callmode; } protected set { callmode = value; } }
        /// <summary>
        /// 放音指定时间后，转called，单位：100ms
        /// </summary>
        public string Playtime { get { return playtime; } protected set { playtime = value; } }
        /// <summary>
        /// 审核后的语音ID（通过PAAS企业管理查询
        /// </summary>
        public string Toneid { get { return toneid; } protected set { toneid = value; } }
        /// <summary>
        /// 在接通后放音的文本内容，可以为空
        /// </summary>
        public string Voice_text { get { return voice_text; } protected set { voice_text = value; } }
        /// <summary>
        /// IvrID
        /// </summary>
        public string Ivrid { get { return ivrid; } protected set { ivrid = value; } }
        /// <summary>
        /// 坐席组编号
        /// </summary>
        public string Groupid { get { return groupid; } protected set { groupid = value; } }
        /// <summary>
        /// 呼叫完成后，坐席按键回调，系统向该地址发送POST请求
        /// </summary>
        public string Collectinfocallback { get { return collectinfocallback; } protected set { collectinfocallback = value; } }
        /// <summary>
        /// 坐席按键
        /// </summary>
        public string Input { get { return input; } protected set { input = value; } }
        /// <summary>
        /// 短信内容
        /// </summary>
        public string Content { get { return content; } protected set { content = value; } }
        /// <summary>
        /// 会议id
        /// </summary>
        public string Confid { get { return confid; } protected set { confid = value; } }
        /// <summary>
        /// 分页参数，页码
        /// </summary>
        public string Pageno { get { return pageno; } protected set { pageno = value; } }
        /// <summary>
        /// 分页参数，每页记录数
        /// </summary>
        public string Pagesize { get { return pagesize; } protected set { pagesize = value; } }
        /// <summary>
        /// 终端MAC地址
        /// </summary>
        public string Mac { get { return mac; } protected set { mac = value; } }
        /// <summary>
        /// Sip账户\坐席号码
        /// </summary>
        public string Number { get { return number; } protected set { number = value; } }
        /// <summary>
        /// 密码
        /// </summary>
        public string Password { get { return password; } protected set { password = value; } }
        /// <summary>
        /// 企业管理员登录账户
        /// </summary>
        public string Account { get { return account; } protected set { account = value; } }
        /// <summary>
        /// 旧密码
        /// </summary>
        public string Oldpassword { get { return oldpassword; } protected set { oldpassword = value; } }
        /// <summary>
        /// 设备厂家ID
        /// </summary>
        public string Devicevendorid { get { return devicevendorid; } protected set { devicevendorid = value; } }
        /// <summary>
        /// 设备类型
        /// </summary>
        public string Devicetype { get { return devicetype; } protected set { devicetype = value; } }
        /// <summary>
        /// 设备ID
        /// </summary>
        public string Deviceid { get { return deviceid; } protected set { deviceid = value; } }
        /// <summary>
        /// 短信结果通知:[0]短信发送成功 [1]短信发送失败
        /// 查询会议状态:可选条件，0是未开始，1是会议中，2是已结束
        /// 设置坐席忙闲状态:坐席状态:1：设置为闲， 3：设置为免打扰，其它值无效
        /// </summary>
        public string Status { get { return status; } protected set { status = value; } }

        /// <summary>
        /// 视频会议屏幕模式：
        /// 0_一大多小画面
        /// 1_一大多小画面（音量大的自动为主画面）
        /// 2_等大画面
        /// </summary>
        public string Screenmode { get { return screenmode; } protected set { screenmode = value; } }

        /// <summary>
        /// 视频会议多画面时，最大显示方数（目前支持4和6）
        /// </summary>
        public string Picnum { get { return picnum; } protected set { picnum = value; } }

        public string Title { get => title; set => title = value; }
        public string Rtmppush { get => rtmppush; set => rtmppush = value; }
        public string Loginname { get => loginname; set => loginname = value; }
        public string Filename { get => filename; set => filename = value; }
        public string Operation { get => operation; set => operation = value; }

        /// <summary>
        /// 回调数据
        /// </summary>
        public CallBackData CallBackData;

        #endregion


        #region 回调

        public CallBackBase ServiceCallBack;

        //public CallBackBase ServiceCallBack { get{ return serviceCallBack; protected set => serviceCallBack = value; }

        #endregion

        public virtual void SetCallBack()
        {

        }













        /// <summary>
        /// 消息签名，见“数字签名算法”
        /// 1、将HTTP请求参数按参数名以字典顺序排序；
        /// 2、将请求参数名和参数值以=连接；
        /// 3、将步骤2中得到的各字符串按步骤1规定的顺序连接，连接时使用&作为分隔；
        /// 4、对步骤3得到的字符串求MD5散列值，并按16进制方式编码为字符串（如有字母则小写）；
        /// 5、将步骤4得到的字符串与签名密钥连接，连接时不使用分隔符；
        /// 6、对步骤5得到的字符串再求一次MD5散列值，并按16进制方式编码为字符串（如有字母则小写）；
        /// </summary>
    }
}
